package com.caocaog.market.finance.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

@Getter
@AllArgsConstructor
public enum WithdrawType {


    /**
     * 商家
     */
    MERCHANT(1),

    /**
     * 分站
     */
    SITE(2);


    @EnumValue
    @JsonValue
    private final Integer code;

    @JsonCreator
    public static WithdrawType match(int type) {
        return Stream.of(WithdrawType.values())
                .filter(s -> s.getCode().equals(type))
                .findAny()
                .orElseThrow(() -> new IllegalArgumentException("未知的提现类型"));
    }

}
